Bundle the plugin SDK declaration files in parallel worker threads - #2304
Merged
Conversation
build-bundled-dts.mjs ran its 13 rollup-plugin-dts bundles one after another, and each builds its own TypeScript program; the six large entries take 2-7s apiece, 27s in total. The entries are independent, so the script now re-runs itself as a worker thread per entry, as many at a time as there are cores. Output is byte-identical; on a 16-core machine the task drops to ~10s. On a 4-CPU runner that is already saturated by turbo it is neutral. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
@get-bb/plugin-sdk#build:types(scripts/build-bundled-dts.mjs) produces the 13 portable declaration bundles one after another. Eachrollup-plugin-dtsbundle builds its own TypeScript 6 program over the SDK sources plus the inlined@bb/*workspace sources; the six large entries take 2–7 s apiece and the task takes ~27 s on a 16-core machine. It gates@bb/host-daemon#build,@bb/cli#test,@bb/templates#test, and@bb/integration-tests#typecheck.What changed
The bundles are independent, so the script re-runs itself as a
worker_threadsworker per entry, keeping as many in flight asos.availableParallelism(). The main thread still writes the outputs in the declared order with the same unchanged-file check and atomic rename. Nothing about the bundling itself changed.How you verified
sha256sum bundled-types/*.d.tsis identical before and after for all 13 files, both on 16 cores and pinned to 4 CPUs. Wall time: 27.0 s → 10.6 s on 16 cores; 27 s → 17.8 s pinned to 4 CPUs standalone. Inside a 4-CPU emulation of the CI "Checks" job (taskset -c 0-3 turbo run build typecheck lint --force --concurrency=4, two rounds each) the job measured 118 s / 99 s serial vs 92 s / 103 s parallel — within run-to-run noise, so expect no CI regression and a clear local win.pnpm exec turbo run test --filter=@get-bb/plugin-sdk --filter=@bb/templates --forceandturbo run typecheck --filter=@bb/integration-tests --filter=@bb/host-daemon --forcepass against the new bundles.No linked issue.